from api import log
from config import HOST


class ApiRecharge:
    #初始化
    def __init__(self,session):
        self.session=session
        self.__url_code=HOST+"/common/public/verifycode/{}"
        self.__url_recharge=HOST+"/trust/trust/recharge "

    #1、充值验证码封装
    def api_code(self,random):
        log.info(f"指针调用充值验证码接口，请求url{self.__url_code.format(random)}")
        return self.session.get(url=self.__url_code.format(random))

    #2、后台充值接口封装
    def api_recharge(self):
        data= {"paymentType": "chinapnrTrust",
               "amount": "1000",
               "formStr": "reForm",
               "valicode": "8888"}
        log.info(f"指针调用充值验证码接口，请求url{self.__url_recharge},请求参数为{data}")
        return self.session.post(url=self.__url_recharge,data=data)
